package com.devshephard.pdf;

import com.alibaba.fastjson.JSON;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestExcel2 {
    public static void main(String[] args) throws IOException {

        //创建工作簿对象
        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream("D:\\zzsFolder\\0zzs_res.xlsx"));
        //获取工作簿下sheet的个数
        int sheetNum = xssfWorkbook.getNumberOfSheets();
        XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
        System.out.println("该excel文件中总共有："+sheetNum+"个sheet");
        LocalInfo[][] res = new LocalInfo[26][8];


        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < 8; j++) {
                LocalInfo localInfo = new LocalInfo();
                XSSFCell cell = sheet.getRow(i).getCell(j);
                localInfo.setLocal_x(i);
                localInfo.setLocal_y(j);
                localInfo.setData(cell.getStringCellValue().replace("\n",""));
                res[i][j] = localInfo;
            } 
        }

        System.out.println(JSON.toJSONString(res));
    }

}
